package com.yoona.sms.controller;

import com.yoona.common.response.BaseResponse;
import com.yoona.sms.SmsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Email: m15602498163@163.com
 * @Author: yoonada
 * @Date: 2020/9/21
 * @Time: 8:55 下午
 * @Msg:
 */
@Api(tags = "腾讯短信服务")
@CrossOrigin
@RestController
@RequestMapping("/sms")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class SmsController {

    private final SmsService smsService;

    @ApiOperation("发送手机验证码")
    @PostMapping(value = "/sendCode")
    public BaseResponse<Object> sendMessage(@RequestParam("mobilePhoneNumber") String mobilePhoneNumber) {
        return smsService.sendMessage(mobilePhoneNumber);
    }

    @ApiOperation("校验验证码")
    @PostMapping(value = "/checkIsCorrectCode")
    public BaseResponse<Object> checkVerificationCode(@RequestParam("mobilePhoneNumber") String mobilePhoneNumber, @RequestParam("verificationCode") String verificationCode) {
        return smsService.checkVerificationCode(mobilePhoneNumber, verificationCode);
    }

}
